﻿using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace HobSoft.SoccerBet2014.Domain.Models.DbSchema
{
    public class BFRunnerConfiguration : EntityTypeConfiguration<BFRunner>
    {
        public BFRunnerConfiguration(string schema = "dbo")
        {
            ToTable(schema + ".BFRunner");
            HasKey(r => new { r.MarketID, r.SelectionID });

            Property(r => r.MarketID).HasColumnName("MarketID").IsRequired().HasMaxLength(50).IsUnicode(false).HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
            Property(r => r.SelectionID).HasColumnName("SelectionID").IsRequired().HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
            Property(r => r.RunnerName).HasColumnName("RunnerName").IsRequired().HasMaxLength(300);
            Property(r => r.OrderIndex).HasColumnName("OrderIndex").IsRequired();
            Property(r => r.Handicap).HasColumnName("Handicap").IsRequired();
            Property(r => r.AsianLineId).HasColumnName("AsianLineId").IsRequired();
            Property(r => r.TotalMatched).HasColumnName("TotalMatched").IsRequired();
            Property(r => r.LastPrice).HasColumnName("LastPrice").IsRequired();
            Property(r => r.LP1).HasColumnName("LP1").IsRequired();
            Property(r => r.LP2).HasColumnName("LP2").IsRequired();
            Property(r => r.LP3).HasColumnName("LP3").IsRequired();
            Property(r => r.BP1).HasColumnName("BP1").IsRequired();
            Property(r => r.BP2).HasColumnName("BP2").IsRequired();
            Property(r => r.BP3).HasColumnName("BP3").IsRequired();
            Property(r => r.LA1).HasColumnName("LA1").IsRequired();
            Property(r => r.LA2).HasColumnName("LA2").IsRequired();
            Property(r => r.LA3).HasColumnName("LA3").IsRequired();
            Property(r => r.BA1).HasColumnName("BA1").IsRequired();
            Property(r => r.BA2).HasColumnName("BA2").IsRequired();
            Property(r => r.BA3).HasColumnName("BA3").IsRequired();
            //Ignore(r => r.Market);
            Ignore(r => r.Key);

            HasRequired(r => r.Market).WithMany(m => m.Runners).HasForeignKey(r => r.MarketID);
        }
    }
}
